package com.kx.yooli.kx.wechat.mapper.credit;

import com.kx.yooli.kx.wechat.entity.credit.CreditEntity;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author john_sqwen-childe.wen
 * date 2024/5/23
 * PROJECT_NAME wechat
 * description create ICreditMapper by john_sqwen
 * and  value is
 */
@UseDataSource("cr")
public interface ICreditMapper extends BaseMapper<CreditEntity> {
    @Select("select c.id,c.name as custName,c.id_card as idCard,c.business_no as businessNo," +
            "(case when h.data_type='9060' then '征信查询' when h.data_type='9064' then '征信有逾期处理' when h.data_type='9065'" +
            "then '征信有还款记录' when h.data_type='9066' then '征信还款到期时' when h.data_type='9069' then '征信已还清当笔' end) as dataType," +
            "(case when c.available ='1' then '有效' else '无效' end) as available " +
            " from credit_zixin_contract c " +
            "inner join credit_zixin_push_history h on h.contract_id = c.id  where c.id_card=#{idCard,jdbcType=VARCHAR}")
    List<CreditEntity> selectByIddCar(String idCard);
    @Select("select count(id) from credit_zixin_contract where  id_card=#{idCard,jdbcType=VARCHAR} ")
    Integer selectCountByCertNo(String idCard);
}
